//
//  XMURL+Extension.swift
//  AnneKit-Swift
//
//  Created by 寜小陌 on 2021/3/8.
//  Copyright © 2021 宁小陌. All rights reserved.
//

import Foundation

extension URL {
    /// 快速实现获取url中的参数，直接返回json对象
    public var nxm_parametersFromQueryString : [String: String]? {
        guard let components = URLComponents(url: self, resolvingAgainstBaseURL: true),
        let queryItems = components.queryItems else { return nil }
        return queryItems.reduce(into: [String: String]()) { (result, item) in
            result[item.name] = item.value
        }
    }
}
